<?php
namespace App\Http\Controllers\Index;

use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Http\Models\Article;
use App\Http\Models\Cate;
use Illuminate\Support\Facades\Session;
class IndexController extends Controller{
	//登录实现
	public function login()
	{
		return view('index/index.login');
	}

	public function do_login(Request $request)
	{
		$gm_name = $request->name;
		$gm_pwd = $request->pwd;

		$result = DB::table('gm')->where(['gm_name'=>$gm_name ,'gm_pwd'=>$gm_pwd])->first();

		if($result){
			Session::push('id',$result->id);
			Session::push('gm_name',$result->gm_name);
			Session::push('gm_pwd',$result->gm_pwd);
			//$res = Session::all();
			//var_dump($res);die;
			return redirect('index/list');

		}else{

			return redirect('index/login');
		}
	}

	//后台首页
	public function list()
	{
		return view('index/index.list');
	}

	public function introduce()
	{
		return view('index/index.introduce');
	}
}